package com.dynamixsoftware.printershare.smb;

class SmbComSessionSetupAndX
  extends AndXServerMessageBlock
{
  private static final int BATCH_LIMIT = 1;
  private static final boolean DISABLE_PLAIN_TEXT_PASSWORDS = true;
  private String accountName;
  private byte[] blob = null;
  private int capabilities;
  private byte[] lmHash;
  private byte[] ntHash;
  private String primaryDomain;
  private SmbSession session;
  private int sessionKey;
  
  SmbComSessionSetupAndX(SmbSession paramSmbSession, ServerMessageBlock paramServerMessageBlock, Object paramObject)
    throws SmbException
  {
    super(paramServerMessageBlock);
    this.command = 115;
    this.session = paramSmbSession;
    this.sessionKey = paramSmbSession.transport.sessionKey;
    this.capabilities = paramSmbSession.transport.capabilities;
    if (paramSmbSession.transport.server.security == 1)
    {
      if ((paramObject instanceof NtlmPasswordAuthentication))
      {
        NtlmPasswordAuthentication localNtlmPasswordAuthentication2 = (NtlmPasswordAuthentication)paramObject;
        if (localNtlmPasswordAuthentication2 == NtlmPasswordAuthentication.ANONYMOUS)
        {
          this.lmHash = new byte[0];
          this.ntHash = new byte[0];
          this.capabilities = (0x7FFFFFFF & this.capabilities);
        }
        do
        {
          this.accountName = localNtlmPasswordAuthentication2.username;
          if (this.useUnicode) {
            this.accountName = this.accountName.toUpperCase();
          }
          this.primaryDomain = localNtlmPasswordAuthentication2.domain.toUpperCase();
          return;
          if (!paramSmbSession.transport.server.encryptedPasswords) {
            break;
          }
          this.lmHash = localNtlmPasswordAuthentication2.getAnsiHash(paramSmbSession.transport.server.encryptionKey);
          this.ntHash = localNtlmPasswordAuthentication2.getUnicodeHash(paramSmbSession.transport.server.encryptionKey);
        } while ((this.lmHash.length != 0) || (this.ntHash.length != 0));
        throw new RuntimeException("Null setup prohibited.");
        throw new RuntimeException("Plain text passwords are disabled");
      }
      if ((paramObject instanceof byte[]))
      {
        this.blob = ((byte[])paramObject);
        return;
      }
      throw new SmbException("Unsupported credential type");
    }
    if (paramSmbSession.transport.server.security == 0)
    {
      if ((paramObject instanceof NtlmPasswordAuthentication))
      {
        NtlmPasswordAuthentication localNtlmPasswordAuthentication1 = (NtlmPasswordAuthentication)paramObject;
        this.lmHash = new byte[0];
        this.ntHash = new byte[0];
        this.accountName = localNtlmPasswordAuthentication1.username;
        if (this.useUnicode) {
          this.accountName = this.accountName.toUpperCase();
        }
        this.primaryDomain = localNtlmPasswordAuthentication1.domain.toUpperCase();
        return;
      }
      throw new SmbException("Unsupported credential type");
    }
    throw new SmbException("Unsupported");
  }
  
  int getBatchLimit(byte paramByte)
  {
    if (paramByte == 117) {
      return 1;
    }
    return 0;
  }
  
  int readBytesWireFormat(byte[] paramArrayOfByte, int paramInt)
  {
    return 0;
  }
  
  int readParameterWordsWireFormat(byte[] paramArrayOfByte, int paramInt)
  {
    return 0;
  }
  
  public String toString()
  {
    StringBuilder localStringBuilder1 = new StringBuilder().append("SmbComSessionSetupAndX[").append(super.toString()).append(",snd_buf_size=").append(this.session.transport.snd_buf_size).append(",maxMpxCount=").append(this.session.transport.maxMpxCount).append(",VC_NUMBER=").append(1).append(",sessionKey=").append(this.sessionKey).append(",lmHash.length=");
    int i;
    StringBuilder localStringBuilder2;
    int j;
    if (this.lmHash == null)
    {
      i = 0;
      localStringBuilder2 = localStringBuilder1.append(i).append(",ntHash.length=");
      byte[] arrayOfByte = this.ntHash;
      j = 0;
      if (arrayOfByte != null) {
        break label203;
      }
    }
    for (;;)
    {
      return new String(j + ",capabilities=" + this.capabilities + ",accountName=" + this.accountName + ",primaryDomain=" + this.primaryDomain + ",NATIVE_OS=" + "Android" + ",NATIVE_LANMAN=" + "PrinterShare" + "]");
      i = this.lmHash.length;
      break;
      label203:
      j = this.ntHash.length;
    }
  }
  
  int writeBytesWireFormat(byte[] paramArrayOfByte, int paramInt)
  {
    if (this.blob != null) {
      System.arraycopy(this.blob, 0, paramArrayOfByte, paramInt, this.blob.length);
    }
    int k;
    for (int m = paramInt + this.blob.length;; m = k + writeString(this.primaryDomain, paramArrayOfByte, k))
    {
      int n = m + writeString("Android", paramArrayOfByte, m);
      return n + writeString("PrinterShare", paramArrayOfByte, n) - paramInt;
      System.arraycopy(this.lmHash, 0, paramArrayOfByte, paramInt, this.lmHash.length);
      int i = paramInt + this.lmHash.length;
      System.arraycopy(this.ntHash, 0, paramArrayOfByte, i, this.ntHash.length);
      int j = i + this.ntHash.length;
      k = j + writeString(this.accountName, paramArrayOfByte, j);
    }
  }
  
  int writeParameterWordsWireFormat(byte[] paramArrayOfByte, int paramInt)
  {
    writeInt2(this.session.transport.snd_buf_size, paramArrayOfByte, paramInt);
    int i = paramInt + 2;
    writeInt2(this.session.transport.maxMpxCount, paramArrayOfByte, i);
    int j = i + 2;
    writeInt2(1L, paramArrayOfByte, j);
    int k = j + 2;
    writeInt4(this.sessionKey, paramArrayOfByte, k);
    int m = k + 4;
    if (this.blob != null) {
      writeInt2(this.blob.length, paramArrayOfByte, m);
    }
    int n;
    for (int i1 = m + 2;; i1 = n + 2)
    {
      int i2 = i1 + 1;
      paramArrayOfByte[i1] = 0;
      int i3 = i2 + 1;
      paramArrayOfByte[i2] = 0;
      int i4 = i3 + 1;
      paramArrayOfByte[i3] = 0;
      int i5 = i4 + 1;
      paramArrayOfByte[i4] = 0;
      writeInt4(this.capabilities, paramArrayOfByte, i5);
      return i5 + 4 - paramInt;
      writeInt2(this.lmHash.length, paramArrayOfByte, m);
      n = m + 2;
      writeInt2(this.ntHash.length, paramArrayOfByte, n);
    }
  }
}


/* Location:           C:\Users\Admin\Desktop\Decompiler\JAD\jd-gui-0.3.6.windows\classes_dex2jar.jar
 * Qualified Name:     com.dynamixsoftware.printershare.smb.SmbComSessionSetupAndX
 * JD-Core Version:    0.7.0.1
 */